fix: handle cross-repo checkpoints when CWD is a different git repo#569
fix: handle cross-repo checkpoints when CWD is a different git repo#569
Conversation
When an AI agent working from repo-1 edits files in repo-2, the checkpoint was only written to repo-1's working log. Files in repo-2 were silently filtered out by path_is_in_workdir, causing all changes to show as 'human' when committing in repo-2. After running the local repo checkpoint, detect any edited files outside the current repo's workdir, group them by their containing repository, and run separate checkpoints for each external repo. Adds three E2E tests covering: - Working log creation in the target repo - AI attribution on commit in the target repo - Preservation of local repo checkpoint alongside cross-repo Co-Authored-By: Sasha Varlamov <sasha@sashavarlamov.com>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
|
|
|
No AI authorship found for these commits. Please install git-ai to start tracking AI generated code in your commits. |
Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
devin fix the lints |
Co-Authored-By: Sasha Varlamov <sasha@sashavarlamov.com>
Co-Authored-By: Sasha Varlamov <sasha@sashavarlamov.com>
|
Devin fix: In src/commands/git_ai_handlers.rs, the Err arm of the checkpoint_result match (lines 843-854) calls std::process::exit(0), which prevents the cross-repo checkpoint processing on lines 856-921 from ever executing when the local checkpoint fails. To fix this, remove the std::process::exit(0) call and instead let execution fall through to the cross-repo processing block. You may want to track whether the local checkpoint succeeded/failed and still report the error, but the key change is to NOT exit the process so that cross-repo checkpoints can still run. This would be consistent with the multi-repo workspace path at lines 692-701 which continues processing other repos on failure. After the cross-repo processing, you can exit with code 0 if the local checkpoint failed (to preserve the existing behavior of not propagating checkpoint errors to callers). |
…ails Remove std::process::exit(0) from the Err arm of the local checkpoint match so that cross-repo checkpoint processing on lines 857-922 can still execute. Track the failure state and exit(0) after cross-repo processing completes, preserving existing behavior for callers. Co-Authored-By: Sasha Varlamov <sasha@sashavarlamov.com>
|
Fixed in 80eef2e. Moved |
fix: handle cross-repo checkpoints when CWD is a different git repo
Summary
When an AI agent working from
repos/repo-1edits files inrepos/repo-2, the checkpoint was only written to repo-1's working log. Files in repo-2 were silently filtered out bypath_is_in_workdirincheckpoint.rs, so all changes showed as "human" when later committing in repo-2.Root cause: In
handle_checkpoint(), when the CWD is itself a git repo,needs_file_based_repo_detectionisfalseand the code falls to the single-repo path. The single-repo checkpoint naturally ignores files outside its workdir — but nothing ever processes those external files.Fix: After running the local repo checkpoint, detect any edited files outside the current repo's workdir, group them by their containing repository via
group_files_by_repository, and run separate checkpoints for each external repo. PassesNoneas workspace boundary since external files are by definition outside the local workspace.Updates since initial revision
workdir(not CWDrepository_working_dir) when resolving relative external paths to absolute, fixing an inconsistency where the containment check and absolute path generation used different base directories.rustfmtformatting differences.ifto satisfyclippy::collapsible_iflint.std::process::exit(0)from theErrarm of the local checkpoint match. Previously, a local checkpoint failure would immediately terminate the process, preventing cross-repo checkpoints from ever executing. Now the failure is tracked vialocal_checkpoint_failed, cross-repo checkpoints run regardless, andexit(0)is called afterward (preserving the existing behavior of not propagating checkpoint errors to callers). This mirrors the multi-repo workspace error handling at lines 692–701, which continues processing other repos on failure.spawn_background_flush()out of theOkarm to after cross-repo processing, so metrics are flushed for cross-repo checkpoints too.Review & Testing Checklist for Human
mock_aiwhich doesn't exercise the full agent preset pipeline. Fromrepos/repo-1, have an AI (Claude Code, Cursor, etc.) edit a file inrepos/repo-2, then commit in repo-2 and rungit-ai blameto confirm AI attribution.exit(0)deferral is safe. The local checkpointErrarm no longer exits immediately — cross-repo checkpoints run first, thenexit(0). Confirm no callers depend on the process exiting before cross-repo side effects occur.AgentRunResultclone cost.agent_run_result.as_ref().cloned()copies the full struct including transcript. For agents with large transcripts, this could be non-trivial memory. Consider whether only the needed fields should be extracted.group_files_by_repository(&external_files, None)with no workspace boundary is acceptable. This walks up the filesystem unbounded looking for.gitdirs. It only runs for files already identified as external, but verify no edge cases with symlinks or deeply nested paths cause issues.Notes